package com.xuan.core.controller.pg;

import com.xuan.core.configuration.result.ResponseResult;
import com.xuan.core.configuration.result.ResponseResultEnum;
import com.xuan.core.dto.pg.PgLiuYaoDto;
import com.xuan.core.service.pg.PgLiuYaoService;
import com.xuan.core.vo.pg.PgLiuYaoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 六爻起卦Controller
 */
@RestController
@RequestMapping("/pgLiuYao")
public class PgLiuYaoController {

    @Autowired
    private PgLiuYaoService PgLiuYaoService; // 六爻起卦Service

//********************************************************************************************************************************

    /**
     * 开始起卦
     *
     * @param dto 六爻起卦数据接收类
     * @return 起卦结果
     */
    @PostMapping("/starts")
    @Cacheable(
            value = "pgLiuYaoStarts",
            key = "'_' + #dto.name + #dto.occupy + #dto.sex + #dto.date.year + #dto.date.month + #dto.date.day + #dto.date.hours + #dto.dateType + " +
                    "#dto.address + #dto.leapMonth + #dto.liuYao + #dto.wuYao + #dto.siYao + #dto.sanYao + #dto.erYao + #dto.yiYao + #dto.yearGanZhiSet + " +
                    "#dto.monthGanZhiSet + #dto.dayGanZhiSet + #dto.hourGanZhiSet",
            condition = "#dto.qiGuaMode == 0"
    )
    public ResponseResult<PgLiuYaoVo> starts(@RequestBody PgLiuYaoDto dto) {

        PgLiuYaoVo vo = PgLiuYaoService.starts(dto);
        return ResponseResult.result(ResponseResultEnum.SUCCESS, vo);

    }


}
